package kgc.LiuMang.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import kgc.LiuMang.service.MessageService;

@Controller
public class MessageController {

	@Autowired
	private MessageService ms;
	
	@RequestMapping("/addMessage.do")
	@ResponseBody
	public int addMessage(@RequestParam String mcontent,@RequestBody Integer mbyid) {
		System.out.println("mcontent:"+mcontent+"mbyid:"+mbyid);
		int succ=0;
		succ=ms.addMessage(mcontent, mbyid);
		if(succ>0) {
			System.out.println("留言成功");
		}
		return succ;
	}
	
	@RequestMapping("/deleteMess.do")
	@ResponseBody
	public int deleteMessage(@RequestBody List<Integer> midlist) {
		System.out.println(midlist);
		int delete=0;
		delete = ms.deletMessageByIdList(midlist);
		if(delete>0) {
			System.out.println("留言删除成功");
		}
		return delete;
	}
}
